<template>
  <div>
    <form action="" method="">
      <table border="1" align="center">
        <tr>
          <td>书名</td>
          <td><input type="text" v-model="b.name"/></td>
        </tr>
        <tr>
          <td>作者</td>
          <td><input type="text" v-model="b.author"/></td>
        </tr>
        <tr>
          <td>价格</td>
          <td><input type="text" v-model="b.price"/></td>
        </tr>
        <tr>
          <td colspan="2">
            <input type="submit" value="修改" @click.prevent="update"/>
          </td>
        </tr>
      </table>
    </form>
  </div>
</template>

<script>
export default {
  name: "Gx",
  data(){
    return{
      b:{}
    }
  },
  created(){
    this.axios.get("books/"+this.$route.query.id)
      .then((resp)=>{
        this.b=resp.data;
        //console.log(this.b);
      });
  },
  methods:{
    update(){
      this.axios.put("books/"+this.$route.query.id,this.b).
      then((resp)=>{
        this.$router.push("/myTable");
      });
    }
  }

}
</script>

<style scoped>

</style>
